package com.yodawnla.littleWar.core;

import java.util.ArrayList;

import com.yodawnla.lib.network.YoClient;
import com.yodawnla.littleWar.system.Values;

public class Client extends YoClient
{
	static ArrayList<ClientHandler> mHandlerList = new ArrayList<ClientHandler>();
	
	static Client instance;
	Client() 
	{
		super(Values.PORT, new ClientHandler());
//		super(Values.PORT, new ClientHandler()
//		{
//			@Override
//			public void onGetResult(String result)
//			{
//				String[] info = result.split("#");
//				int code = Integer.valueOf(info[0]);
//				String data = info[1];
//				
//				for (ClientHandler handler : mHandlerList)
//				{
//					handler.onGetResult(code, data);
//				}
//			}
//			
//			public void onConnected()
//			{
//				for (ClientHandler handler : mHandlerList)
//				{
//					handler.onConnected();
//				}
//			}
//		});
	}
	
	public static Client getInstance()
	{
		if (instance == null)
			instance = new Client();
		return instance;
	}
	
	public void addHandler(ClientHandler handler)
	{
		mHandlerList.add(handler);
	}
}
